var CustomBiz={ name:'Hello World', desc:'说句话:Hello World', status:0,//0未初始化,1正在运行,-1已经关闭 idx:-1, view:null, init:function(CustomBiz,side) { this.side=side; if(side=='server'){ this.view=new dobject('TForm',null); } if(side=='client'){ this.view=new dobject('TForm',null); } if(side=='server'){ var NewButton = new dobject('TButton',this.view); NewButton.Left=8; NewButton.Top=24; NewButton.Width=175; NewButton.Height=41; NewButton.Caption='发送 hello world'; NewButton.Parent=this.view; this.OnNewButtonClick=function(sender){ sender.Parent.Caption=this.desc; flags=0;reply_id='';biz_code=this.name;config_code='';msg_txt='hellow world'; im_helper.PostCustomConferenceMessage(flags,reply_id,biz_code,config_code,msg_txt); } NewButton.OnClick=new Function('sender','var cb=getJsCustomObject('+this.idx+');cb.OnNewButtonClick(sender);'); } this.OnClose=function(sender){ flags=0;reply_id='';biz_code=this.name+'-CLOSE';config_code='';msg_txt='hellow world'; im_helper.PostCustomConferenceMessage(flags,reply_id,biz_code,config_code,msg_txt); stopJsCustom(this.idx); } this.view.OnClose=new Function('sender','var cb=getJsCustomObject('+this.idx+');cb.OnClose(sender);'); this.view.Show(); this.count=0; }, OnCustomConferenceMessage:function(CustomBiz,sender_id,date_time,msg_id,reply_id,flags,biz_code,config_code,msg_txt) { if(biz_code==CustomBiz.name){ CustomBiz.count++; CustomBiz.view.Caption=CustomBiz.name+'-'+CustomBiz.count+'-'+CustomBiz.idx; } if(biz_code==CustomBiz.name+'-CLOSE'){ CustomBiz.view.Close(); } } }; var CustomBiz={ name:'SQLite Pipe', desc:'SQLite隧道', status:0,//0未初始化,1正在运行,-1已经关闭 idx:-1, view:null, init:function(CustomBiz,side) { this.side=side; if(side=='server'){} if(side=='client'){} this.count=0; this.view=window.open("about:blank"); this.view.document.write("建议对方运行的SQL"); this.view.document.write("<textarea id='to_him' style='width:100%;height:160;border:0;padding:2;padding-top:4px;background-color:#F0F0F2;' ></textarea>"); this.view.document.write("发送建议"); this.onSend=function(){ var sql=this.view.document.getElementById('to_him').value; if(sql.length==0) return; flags=0;reply_id='';biz_code=this.name;config_code='';msg_txt=sql; im_helper.PostCustomConferenceMessage(flags,reply_id,biz_code,config_code,msg_txt); }; this.view.document.write("对方建议我运行的SQL"); this.view.document.write("<textarea id='to_me' style='width:100%;height:160;border:0;padding:2;padding-top:4px;background-color:#F0F0F2;' ></textarea>"); this.view.document.write("SQLite 数据库文件:"); this.view.document.write("执行并发送结果至对方"); this.onExecute=function(){ var sql=this.view.document.getElementById('to_me').value; var db3fn=this.view.document.getElementById('db3fn').value; if(sql.length==0 || db3fn.length==0) return; if(this.db3==undefined){ this.db3=new dobject("SQLite3Wrapper"); this.db3.open(db3fn); } var final_html; this.db3.query(sql); var ret=this.db3.sqlite_last_error(); if(ret.length>0){ final_html=ret; }else{ var result_count=0; var table_str=""; var field_count; var fields,i,fn,v; while(this.db3.fetch()){ if(result_count==0){ table_str+="<tr>"; fields=new Array(); field_count=this.db3.get_field_count(); for(i=0;i < field_count;i++){ fn=this.db3.get_field_name_by_index(i); fields.push(fn); table_str+="<td>"; table_str+=fn; table_str+="</td>"; } table_str+="</tr>"; } result_count++; table_str+="<tr>"; for(i=0;i < field_count;i++){ v=this.db3.get_array_data(fields[i]); table_str+="<td>"; table_str+=v; table_str+="</td>"; } table_str+="</tr>"; } if(result_count==0){ final_html='no error, no result.'; }else{ table_str+="</table>"; final_html=table_str; } } this.view.document.getElementById('result').innerHTML=final_html; flags=0;reply_id='';biz_code=this.name+'-RESULT';config_code='';msg_txt=final_html; im_helper.PostCustomConferenceMessage(flags,reply_id,biz_code,config_code,msg_txt); }; this.view.document.write("运行结果"); this.view.document.write(""); this.OnClose=function(){ stopJsCustom(this.idx); flags=0;reply_id='';biz_code=this.name+'-CLOSE';config_code='';msg_txt='hellow world'; im_helper.PostCustomConferenceMessage(flags,reply_id,biz_code,config_code,msg_txt); } }, OnCustomConferenceMessage:function(CustomBiz,sender_id,date_time,msg_id,reply_id,flags,biz_code,config_code,msg_txt) { if(biz_code==CustomBiz.name){ CustomBiz.count++; msg_txt=replaceAll(msg_txt,'"',"""); xxx=CustomBiz.view; setTimeout('xxx.document.getElementById("to_me").value=replaceAll("'+msg_txt+'",""",\'"\')'); } if(biz_code==CustomBiz.name+'-RESULT'){ CustomBiz.count++; msg_txt=replaceAll(msg_txt,'"',"""); xxx=CustomBiz.view; setTimeout('xxx.document.getElementById("result").innerHTML=replaceAll("'+msg_txt+'",""",\'"\')'); } if(biz_code==CustomBiz.name+'-CLOSE'){ xxx=CustomBiz.view; setTimeout('xxx.close()'); } } };